package day12;

public class RunSync {
	
	public static void main(String[] args) {
		RunSync runSync = new RunSync();
		for (int i = 0; i < 5; i++) {
			runSync.runCommonCalculate();
		}
	}
	public void runCommonCalculate() {
		
		CommonCalculate calc = new CommonCalculate();
		ModifyAmountThread thread1 = new ModifyAmountThread(calc, true);
		ModifyAmountThread thread2 = new ModifyAmountThread(calc, true);
		
		thread1.start();
		thread2.start();
		
		try {
			thread1.join(1000);
			thread2.join(2000);
			
			thread1.interrupt();
			
			System.out.println("Final value is " + calc.getAmount());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
